//
//  ViewController.m
//  mqttExample
//
//  Created by GMS on 2021/3/8.
//

#import "ViewController.h"
#import"MQTTClient.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    MQTTCFSocketTransport *transport = [[MQTTCFSocketTransport alloc] init];
    transport.host = @"kfe11d1d.cn.emqx.cloud";
    transport.port = 12996;
    MQTTSession *session = [[MQTTSession alloc] init];
    session.userName = @"arthur";
    session.password = @"123456";
    session.clientId = @"mqtt_zhansan";
    
    session.transport = transport;
    
    [session connectWithConnectHandler:^(NSError *error) {
        
        NSLog(@"error *** %@",error);
        
        
    }];
    
//    [session subscribeToTopic:@"example/#" atLevel:MQTTQosLevelExactlyOnce subscribeHandler:^(NSError *error, NSArray<NSNumber *> *gQoss) {
//        if (error) {
//            NSLog(@"Subscription failed %@", error.localizedDescription);
//        } else {
//            NSLog(@"Subscription sucessfull! Granted Qos: %@", gQoss);
//        }
//     }];
    
    
    
    
}


@end
